/*
 * Copyright (c) 2011
 * Huawei.shen@gmail.com All rights reserved
 *
 * This file is a part os Iplite46 software which is a lightweight IPv4/IPv6
 * protocol stack.
 * 
 * !@file: strncpy.c
 *   describtion:
 *   A simple implemenation of standard c library function 'strncpy'
 */
#include "utils.h"

INT32 _lite_strncpy (INT8 * dst, INT8 * src, INT32 len)
{
    if (len < 0)
        return ERR_PARM;

    INT32 _len = _lite_strlen (src);
    if(_len < len)
    {
        _lite_strcpy(dst, src);
    }
    else
    {
        _lite_memcpy (dst, src, len);
        dst[len - 1] = '\0';
    }

    return LITE_MINOF(_len, len); 
}

